package com.mall.service.item;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.client.item.ItemCategoryService;
import com.mall.custom.dao.read.ItemCategoryReadMapper;
import com.mall.pojo.ItemCategory;
import com.mall.pojo.ItemCategoryExample;
import com.mall.pojo.ItemCategoryExample.Criteria;
@Service
public class ItemCategoryServiceImpl implements ItemCategoryService {

	@Autowired
	private ItemCategoryReadMapper itemCategoryReadMapper;
	@Override
	public ItemCategory getItemCategoryById(Long itemCategoryId) {
		
		return this.itemCategoryReadMapper.selectByPrimaryKey(itemCategoryId);
	}
	@Override
	public List<ItemCategory> getItemCategoryListByMallId(Long mallId, Integer onlyKey) {
		if(mallId == null || onlyKey == null){
			return null;
		}
		ItemCategoryExample example = new ItemCategoryExample();
		Criteria criteria = example.createCriteria();
		criteria.andMallIdEqualTo(mallId);
		criteria.andStatusEqualTo(0);
		criteria.andCommOnlyKeyEqualTo(onlyKey);
		return itemCategoryReadMapper.selectByExample(example);
	}

}
